local game = require "club.threecard.blackjack"

local phase_shower = game.ui.element()

local log = game.logging.get("phase_shower")

phase_shower.store_watchers = 
{
    ingame = 
    {
        ["确认保险"] = function(self, store, state, args, initialize)
            if initialize then
                return;
            end

            self.txt.text = state.tip_phase;
        end,

        ["阶段变更"] = function(self, store, state, args)

            if state.phase == state.PHASE.IDLE then
                --self:show();
                self.txt.text = state.tip_phase;
            elseif state.phase == state.PHASE.PREPARE then
                --self:show();
                self.txt.text = state.tip_phase;
                game.audio.post("blackjack:tips_operate");
            elseif state.phase == state.PHASE.DEAL then
                --self:show()
                self.txt.text = state.tip_phase;
            elseif state.phase == state.PHASE.INSURE then
                if state.self_playing then
                    self:show();
                    game.audio.post("blackjack:tips_operate");
                    self.txt.text = state.tip_phase;
                end
            else
                self:hide();
            end
        end,

        ["countdown变更"] = function(self, store, state, args, initialize)
            self.txt.text = state.tip_phase;
        end
    }
}

function phase_shower:ctor()
    self.res = "club.threecard.blackjack/ui/ingame.b:phase_shower"
end

return phase_shower